#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include<signal.h>
#include<sys/types.h>
static void sig_handler(int sig)
{
	printf("received signal:%d\n",sig);
}
int main(void)
{
	struct sigaction sig={0};
	sigset_t wait_mask;
	sigemptyset(&wait_mask);

	sig.sa_handler=sig_handler;
	sig.sa_flags=0;
	if(-1==sigaction(SIGUSR1,&sig,NULL)){
		perror("sigaction error");
		exit(-1);
	}
	switch(fork()){
		case -1:
			perror("fork error");
			exit(-1);
		case 0:
			printf("child process start:\n");
			printf("child print info\n");
			printf("~~~~~~~~~~~~~~~~~\n");
			sleep(2);
			kill(getppid(),SIGUSR1);
			_exit(0);
		default:
			if(-1!=sigsuspend(&wait_mask))
				exit(-1);
			printf("parent process start\n");
			printf("parent print info\n");
			exit(0);
	}
}
